using System;
using System.ComponentModel;
using System.Xml.Serialization;

namespace com.exceptionalsoftware.spacetime.KML
{
	[Serializable()]
    [XmlType(TypeName = "SimpleFieldType")]
    public class SimpleFieldType
	{
        private string displayNameField;
        private string typeField;
        private string nameField;

        [XmlElement(ElementName = "displayName", DataType = "string")]
        public string displayName
        {
            get { return this.displayNameField; }
            set { this.displayNameField = value; }
        }

        [XmlAttribute(AttributeName = "type", DataType = "string")]
        public string type
        {
            get { return this.typeField; }
            set 
            { 
                string[] allowed = new string[] { "string", "int", "uint", "short", "ushort", "float", "double", "bool" };
                string val = value.ToLower();
                bool found = false;
                for (int i = 0; i < allowed.Length; i++)
                {
                    if (val == allowed[i].ToLower())
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                    val = "string";

                this.typeField = val; 
            }
        }

        [XmlAttribute(AttributeName = "name", DataType = "string")]
        public string name
        {
            get { return this.nameField; }
            set { this.nameField = value; }
        }
    }
}